define([
    "esri/layers/GeoJSONLayer"
], function(GeoJSONLayer) {
    var geoJSONLayer = GeoJSONLayer.createSubclass({
        setData: function(mapView, layer) {
            var me = this;
            if (!mapView) {
                return
            };
            var options = layer.layer || {};
            var data = options.data || [];

            if (typeof options.callback == 'function') {
                options.callback(me);
            };
        },
        getGraphicLocation: function(mapView, esriEvent, mapUtils) {
            var me = this;
            var location = null;

            var _geometryType = esriEvent.graphic.geometry.type;
            switch (_geometryType) {
                case mapUtils.Enum.GType.Point:
                    location = me.getPointGraphicLocation(mapView, esriEvent);
                    break;
                case mapUtils.Enum.GType.Polyline:
                    location = me.getPolylineGraphicLocation(mapView, esriEvent);
                    break;
                case mapUtils.Enum.GType.Extent:
                case mapUtils.Enum.GType.Circle:
                case mapUtils.Enum.GType.Polygon:
                    location = me.getPolygonGraphicLocation(mapView, esriEvent);
                    break;
            };
            return location;
        },
        getPointGraphicLocation: function(mapView, esriEvent) {
            if (!esriEvent || !esriEvent.graphic) {
                return;
            }
            var geometry = esriEvent.graphic.geometry || {};

            var lngFieldName = mapView.getLngFieldName();
            var latFieldName = mapView.getLatFieldName();
            var location = {};
            location[lngFieldName] = geometry.longitude;
            location[latFieldName] = geometry.latitude;
            return location;
        },
        getPolylineGraphicLocation: function(mapView, esriEvent) {
            if (!esriEvent || !esriEvent.mapPoint) {
                return;
            }
            var geometry = esriEvent.mapPoint || {};

            var lngFieldName = mapView.getLngFieldName();
            var latFieldName = mapView.getLatFieldName();
            var location = {};
            location[lngFieldName] = geometry.longitude;
            location[latFieldName] = geometry.latitude;
            return location;
        },
        getPolygonGraphicLocation: function(mapView, esriEvent) {
            if (!esriEvent || !esriEvent.mapPoint) {
                return;
            }
            var geometry = esriEvent.mapPoint || {};
            var lngFieldName = mapView.getLngFieldName();
            var latFieldName = mapView.getLatFieldName();
            var location = {}
            location[lngFieldName] = geometry.longitude;
            location[latFieldName] = geometry.latitude;
            return location;
        }
    });
    return geoJSONLayer;
});